// pages/personInfo/personInfo.js
var app = getApp() 
Page({
  data: {
    success:false,
    personInfoModify:false,
    educationShow: true,
    schoolShow: true,
    workShow: true,
    workExp: [],
    education: [],
    necessary:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    var that = this
    //调用应用实例的方法获取全局数据  
    app.getUserInfo(function (userInfo) {
      //更新数据  
      that.setData({
        userInfo: userInfo
      })
    })
    wx.getStorage({
      key: 'personInfoData',
      success: function (res) {
        console.log(that.data.personInfo)
        that.setData({
          personInfo: res.data
        })
        if(that.data.personInfo.identity=="毕业生"){
          that.setData({
            necessary: true
          })
        }else{
          that.setData({
            necessary: false
          })
        }
        if (that.data.personInfo) {
          that.setData({
            success:true,
            personInfoModify: true,
          })
        }
      },
    });
    wx.getStorage({
      key: 'education',
      success: function (res) {
        that.setData({
          education: res.data
        })
        if (that.data.education) {
          that.setData({
            educationShow: false,
          })
        }
      },
    });
    wx.getStorage({
      key: 'workExp',
      success: function (res) {
        that.setData({
          workExp: res.data
        })
        if (that.data.workExp) {
          that.setData({
            workShow: false,
          })
        }
      },
    });
  },
  infoAdd: function () {
    wx.navigateTo({
      url: 'infoDetail/infodetail',//../resume/personInfo/personInfo
    })
  },
  infoModify: function () {
    wx.navigateTo({
      url: 'infoDetail/infodetail',
    })
  },
  educationAdd: function () {
    wx.navigateTo({
      url: '../resume/education/education',
    })
  },
  workAdd: function () {
    wx.navigateTo({
      url: '../resume/workExp/workExp',
    })
  },
  educationModify: function (e) {
    var that = this;
    var educationData = e.currentTarget.dataset.educationdata;
    var educationIndex = e.currentTarget.dataset.educationindex;
    wx.navigateTo({
      url: '../resume/education/education?educationData=' + JSON.stringify(educationData) + '&&educationIndex=' + educationIndex,
    })
  },
  workModify: function (e) {
    var that = this;
    var workData = e.currentTarget.dataset.workdata;
    var workIndex = e.currentTarget.dataset.workindex;
    wx.navigateTo({
      url: '../resume/workExp/workExp?workData=' + JSON.stringify(workData) + '&&workIndex=' + workIndex,
    })
  },
  educationContinue: function () {
    wx.navigateTo({
      url: '../resume/education/education',
    })
  },
  workContinue: function () {
    wx.navigateTo({
      url: '../resume/workExp/workExp',
    })
  },
})